from typing import * 
class Solution:
    def deleteGreatestValue(self, grid: List[List[int]]) -> int:
        n = len(grid[0])
        mx = [0] * n
        for row in grid:
            row.sort(reverse=True)
            for i in range(len(row)):
                mx[i] = max(mx[i],row[i])
        return sum(mx)